package com.ruibang.glass.material.controller.container;

import com.ruibang.glass.material.domain.req.BucketLoadReq;
import com.ruibang.glass.material.domain.req.BucketManagerReq;
import com.ruibang.glass.material.domain.req.BucketUnloadReq;
import com.ruibang.glass.material.domain.req.ContainerTransferReq;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruibang.glass.material.service.BucketManagerService;
import com.ruibang.glass.material.entity.BucketManager;


import javax.validation.Valid;


/**
 * <p>
 * 料罐管理 前端控制器
 * </p>
 *
 * @author songJinKang
 * @since 2024-03-26
 */
@RestController
@RequestMapping("/api/material/bucket/manager")
@Api(tags = "料罐管理控制器")
public class BucketManagerController {

    @Autowired
    private BucketManagerService bucketManagerService;

    @GetMapping("/getById/{id}")
    @ApiOperation(value = "获取料罐管理", notes = "获取料罐管理")
    public ResultBody getById(@PathVariable(value = "id") Integer id) {
        return ResultBody.success(bucketManagerService.getById(id));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增料罐管理", notes = "新增料罐管理")
    public ResultBody save(@RequestBody @Valid BucketManager bucketManager) {
        bucketManagerService.insert(bucketManager);
        return ResultBody.success();
    }

    @PutMapping("/edit")
    @ApiOperation(value = "修改料罐管理", notes = "修改料罐管理")
    public ResultBody edit(@RequestBody BucketManager bucketManager) {
        return bucketManagerService.edit(bucketManager);
    }

    @DeleteMapping("/deleteById/{id}")
    @ApiOperation(value = "修改料罐管理", notes = "修改料罐管理")
    public ResultBody deleteById(@PathVariable String id) {
        bucketManagerService.deleteById(id);
        return ResultBody.success();
    }

    @PostMapping("/list")
    @ApiOperation(value = "非分页列表查询料罐管理", notes = "非分页列表查询料罐管理")
    public ResultBody list() {
        return ResultBody.success(bucketManagerService.list());
    }

    @PostMapping("/pageQuery")
    @ApiOperation(value = "分页列表查询料罐管理", notes = "分页列表查询料罐管理")
    public ResultBody<IPage<BucketManager>> page(@RequestBody BucketManagerReq bucketManagerReq) {
        return ResultBody.success(bucketManagerService.pageQuery(bucketManagerReq));
    }


    @PostMapping("/transfer")
    @ApiOperation(value = "容器转移", notes = "容器转移")
    public ResultBody transfer(@RequestBody @Valid ContainerTransferReq containerTransferReq) {
        return bucketManagerService.transfer(containerTransferReq);
    }

    @PostMapping("/load")
    @ApiOperation(value = "装料", notes = "装料")
    public ResultBody load(@RequestBody @Valid BucketLoadReq bucketLoadReq) {
        return bucketManagerService.load(bucketLoadReq);
    }

    @PostMapping("/unLoad")
    @ApiOperation(value = "卸料", notes = "卸料")
    public ResultBody unLoad(@RequestBody @Valid BucketUnloadReq bucketUnloadReq) {
        return bucketManagerService.unLoad(bucketUnloadReq);
    }

}
